<template>
	<view class="content">
		<h2>当前值</h2>
		<view>{{start}}</view>
		<h2>数字滚动插件</h2>
		<digital-rolling :digitTo="digitTo" :digitFrom="digitFrom" :limit="2"></digital-rolling>
	</view>
</template>

<script>
	import digitalRolling from "@/components/digital-rolling/digital-rolling.vue"
	export default {
		components: {
			digitalRolling
		},
		data() {
			return {
				digitTo: 0,
				digitFrom: 0,
				start: 0,
			}
		},
		onLoad() {
			this.timer = setInterval(() => {
				this.start += Math.random() * 10;
				this.makeMove(this.start);
			}, 2000)
		},
		methods: {
			makeMove(start) {
				this.digitFrom = this.digitTo;
				this.digitTo = Number(start);
			}
		},
		onUnload() {
			this.timer && clearInterval(this.timer);
		},
	}
</script>

<style>

</style>
